﻿using System;
using CommonPatterns.DesignPatterns;
using OCDP.Client.Model;

namespace OCDP.Client.Adapters
{
    public class UserAdapter : Adapter<User>
    {
        #region Constructor
        public UserAdapter(User operatorInstance)
            : base(operatorInstance)
        {
            FirstName = operatorInstance.FirstName;
            LastName = operatorInstance.LastName;
            Email = operatorInstance.Email;
            Birth = operatorInstance.Birth;
        }
        #endregion
                
        #region Properties
        private string lastName;
        public string LastName
        {
            get { return lastName; }
            set
            {
                if (lastName != value)
                {
                    lastName = value;
                    RaisePropertyChanged(() => LastName);
                }
            }
        }

        private string firstName;
        public string FirstName
        {
            get { return firstName; }
            set
            {
                if (firstName != value)
                {
                    firstName = value;
                    RaisePropertyChanged(() => FirstName);
                }
            }
        }

        private string email;
        //[RegularExpression(@"\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*", ErrorMessage = "non valid email")]
        public string Email
        {
            get { return email; }
            set
            {
                if (email != value)
                {
                    email = value;
                    RaisePropertyChanged(() => Email);
                }
            }
        }

        private DateTime birth;
        public DateTime Birth
        {
            get { return birth; }
            set
            {
                if (birth != value)
                {
                    birth = value;
                    RaisePropertyChanged(() => Birth);
                }
            }
        }    
        
        private int carNumber;
        //[RangeValidator(2, RangeBoundaryType.Inclusive,100, RangeBoundaryType.Inclusive)]
        public int CarNumber
        {
            get { return carNumber; }
            set
            {
                if (carNumber != value)
                {
                    carNumber = value;
                    RaisePropertyChanged(() => CarNumber);
                }
            }
        }
        #endregion
    }
}
